package com.seng.resourcetycoon.util;
import javafx.scene.control.Alert;
import javafx.scene.control.ButtonType;
import javafx.stage.StageStyle;

import java.util.Optional;

public class ToastUtil {

    public interface  OnBtnCallback{
        void callBack();
    }

    public static void showAlert(String message, String title) {
        showAlert(message,title,null);
    }

    public static void showAlert(String message, String title,OnBtnCallback onBtnCallback) {
        Alert alert = new Alert(Alert.AlertType.INFORMATION);
        alert.initStyle(StageStyle.UTILITY); // Optionally set the window style

        // Set dialog properties
        alert.setTitle(title);
        alert.setHeaderText(null); // Optional header text
        alert.setContentText(message);

        // Optionally handle the result if there are buttons with specific actions
        Optional<ButtonType> result = alert.showAndWait();
        if (result.isPresent() && result.get() == ButtonType.OK) {
            if(onBtnCallback != null){
                onBtnCallback.callBack();
            }
        }
    }
}
